package com.vegetable.modules.service.outbound;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.vegetable.common.utils.PageUtils;
import com.vegetable.common.utils.R;
import com.vegetable.modules.entity.outbound.SalesOrder;
import com.vegetable.modules.entity.outbound.SalesOrderDetail;
import com.vegetable.modules.entity.outbound.SalesOrderTransmit;
import com.vegetable.modules.entity.outbound.SalesOut;
import com.vegetable.modules.entity.outbound.po.CustomerPurchaseAnalysisPO;
import com.vegetable.modules.entity.outbound.po.NoCostWeightListPO;
import com.vegetable.modules.entity.outbound.po.SalesAssignTaskPO;
import com.vegetable.modules.entity.outbound.po.SalesOrderTransmitPO;
import com.vegetable.modules.entity.outbound.vo.CustomerPurchaseAnalysisVO;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 销售订货 服务类
 * </p>
 *
 * @author wangruijie
 * @since 2024-03-27
 */
public interface ISalesOrderService extends IService<SalesOrder> {

    /**
     * 销售订货列表查询
     * @param params
     * @return
     */
    PageUtils queryPage(Map<String, Object> params);

    /**
     * 销售走货列表
     * @param params
     * @return
     */
    PageUtils salesOrderList(Map<String, Object> params);

    /**
     * 复制销售订货
     * @param id null
     * @return R
     * @author wrj
     * @since 2024/3/29 上午11:42
     */
    R copySalesOrder(Long id, Long createUserId) throws Exception;

    /**
     * 详情销售订货
     * @param id null
     * @return R
     * @author wrj
     * @since 2024/3/27 下午4:35
     */
    R detailSalesOrder(Long id);

    /**
     * 根据id查询详组装发货数据（销售出库单）
     * @param id null
     * @return R
     * @author wrj
     * @since 2024/4/1 下午9:30
     */
    R<SalesOut> buildSendGoods(Long id) throws Exception;

    /**
     * 新增销售订货
     * @param salesOrder null
     * @return R
     * @author wrj
     * @since 2024/3/27 下午4:35
     */
    R saveSalesOrder(SalesOrder salesOrder) throws Exception;

    /**
     * 条件查询任务下达列表
     *
     * @param params
     * @return
     */
    List<SalesOrderTransmit> transmitList(SalesOrderTransmitPO po);

    /**
     * 任务下达
     * @param po null
     * @return R
     * @author wrj
     * @since 2024/3/29 下午3:40
     */
    R assignTask(SalesAssignTaskPO po)throws Exception;

    /**
     * 销售订货走货
     * @param salesOrder null
     * @return R
     * @author wrj
     * @since 2024/3/27 下午4:35
     */
    R submitSalesOrder(SalesOrder salesOrder) throws Exception;

    /**
     * 走货
     * @param detail null
     * @return R
     * @author wrj
     * @since 2024/3/29 上午10:40
     */
    R deliverySalesOrder(SalesOrderDetail detail) throws Exception;

    /**
     * 删除销售订货
     * @param id null
     * @return R
     * @author wrj
     * @since 2024/3/27 下午4:35
     */
    R deleteSalesOrder(Long id) throws Exception;

    /**
     * 完成销售订货
     * @param id null
     * @return R
     * @author wrj
     * @since 2024/3/29 上午11:48
     */
    R competeSalesOrder(Long id) throws Exception;

    List<SalesOrderDetail> lastOrder(Long customerId);

    List<SalesOrderDetail> relateOrder(Long customerId);

    R updateRemark(SalesOrder po);


    R oneClickShipping(Long salesOrderId) throws Exception;

    R noCostWeightList(NoCostWeightListPO po) throws Exception;

    R updateSalesOrder(SalesOrder salesOrder) throws Exception;

    R confirmSalesOrder(SalesOrder salesOrder) throws Exception;

    List<Map<String, String>> statisticTask(SalesOrderTransmitPO po);
    
    /**
     * 分析客户采购习惯
     * @param po 查询参数
     * @return 分页结果
     */
    IPage<CustomerPurchaseAnalysisVO> analyzeCustomerPurchase(CustomerPurchaseAnalysisPO po);
}